package com.mew.chess.core.game.lh.game.task;


import com.mew.chess.core.common.handler.ChessPushMessageUtil;
import com.mew.chess.core.game.lh.game.LhGameManager;
import com.mew.chess.core.game.lh.game.LhRoomManager;
import com.mew.chess.core.game.lh.game.common.LhLinkType;
import com.mew.chess.core.game.lh.game.core.LhRobotBetUtils;
import com.mew.chess.core.game.lh.game.message.LhPushBetInfoMessage;
import com.mew.chess.core.game.lh.game.message.LhPushCMDMapType;
import com.zebra.common.concurrent.ZebraScheduler;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ScheduledFuture;

@Slf4j
public class LhPushBetScheduleTask {


    public void robotBet(int roomId, ScheduledFuture<?> stepFuture){
        LhRoomManager controller = LhGameManager.getInstance().getController(roomId);
        if (controller.getLinkType() != LhLinkType.Start.code()){
            if (null != stepFuture){
                ZebraScheduler.cancelScheduled(stepFuture);
            }
            return;
        }

        LhPushBetInfoMessage betInfoResponse = LhRobotBetUtils.sumBetNumber(roomId, true);
        //log.info("Lh push bet Info：us {} {} ", controller.getOnlineUser().size(), betInfoResponse.toString());

        ChessPushMessageUtil.broadcastMessage(controller.getOnlineUser().values(), LhPushCMDMapType.BetInfoMessage.code(),betInfoResponse);
    }





}
